package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.po.voip.ShareLink;
import com.base.service.ShareLinkService;

/**
 * 分享链接内容服务端
 * 
 * @author 
 *
 */
@Controller
@RequestMapping("/admin")
public class index_ShareLink {

	@Autowired
	private ShareLinkService shareLinkService; // 分享链接

	// 分享链接内容
	@RequestMapping("/shareLinkIndex")
	public ModelAndView shareLinkIndex(HttpServletRequest request) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return new ModelAndView("jsp/loginCheck");  // 未登录
		return new ModelAndView("jsp/index_ShareLink", "list",
				shareLinkService.selectByAll(new ShareLink(userid, (byte)1)));
	}

	// 跳转添加分享链接内容
	@RequestMapping("/addShareLink")
	public String addShareLink() throws Exception {
		return "jsp/add_ShareLink";
	}

	// 跳转修改分享链接内容
	@RequestMapping("/updateShareLink")
	public ModelAndView updateShareLink(String id) throws Exception {
		return new ModelAndView("jsp/update_ShareLink", "shareLink", shareLinkService.selectByPrimaryKey(id));
	}
}
